<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li{
            width: 300px;
            height:30px;
            line-height: 30px;
            border:1px solid red;
        }
    </style>
</head>
<body>
    <h3>用户列表</h3>
    <button>添加li</button>
    <ul>
        <li>123</li>
    </ul>
    <div>我是div</div>
    <div>我是div</div>
    <script>
        // 1. 获取元素
        let oBtn = document.querySelector('button');
        let oUl = document.querySelector('ul');
        // 2. 按钮绑定单击事件
        oBtn.onclick = function(){
            // 创建一个文档碎片
            const fragment = document.createDocumentFragment();
            for(let i = 0; i < 3; i++){
                // 创建一个li
                let oLi = document.createElement('li');
                oLi.innerHTML = i;
                fragment.appendChild(oLi);
            }

            oUl.appendChild(fragment);
        }

        // 文档碎片
        
    </script>
</body>
</html>